using System.Linq;
using System.Collections.Generic;
using Managistics.Model;

namespace Managistics.Core.Repositories.Impl
{
    public class GoodRepository : RepositoryBase<Good, string>, IGoodRepository
    {
        public List<Good> GetGoodsOfItemType(string itemTypeCode)
        {
            return GetAll().Where(good => good.ItemType.Code == itemTypeCode).ToList();
        }

        /// <summary>
        /// Get Good by good code
        /// </summary>
        /// <param name="goodId">The good code</param>
        /// <returns>object good</returns>
        public Good GetGoodById(string goodId)
        {
            return this.Session.Get<Good>(goodId);
        }

        public void UpdateGood(Good good)
        {
            this.Session.Update(good);
            this.Session.Flush();
        }
    }
}